﻿using System;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class FileSharedWith : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public FileAccess Access { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public FileSharedWith(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(String jsonText)
        {
            var d = this.SetData(jsonText);
            FileAccess fileAccess = FileAccess.JustMe;
            switch (d.ToString("access"))
            {
                case "People I selected":
                    fileAccess = FileAccess.PeopleISelected;
                    break;
                case "Just me":
                    fileAccess = FileAccess.JustMe;
                    break;
                case "Everyone (public)":
                    fileAccess = FileAccess.Everyone;
                    break;
                case "Friends":
                    fileAccess = FileAccess.Friends;
                    break;
                case "My friends and their friends":
                    fileAccess = FileAccess.MyFriendsAndTheirFriends;
                    break;
                case "People with a link":
                    fileAccess = FileAccess.PeopleWithALink;
                    break;
            }
            this.Access = fileAccess;
        }
    }

    /// <summary>
    /// 
    /// </summary>
    public static class SharedWith
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="fa"></param>
        /// <returns></returns>
        public static String GetAccess(FileAccess fa)
        {
            switch (fa)
            {
                case FileAccess.PeopleISelected:
                    return "People I selected";
                case FileAccess.JustMe:
                    return "Just me";
                case FileAccess.Everyone:
                    return "Everyone (public)";
                case FileAccess.Friends:
                    return "Friends";
                case FileAccess.MyFriendsAndTheirFriends:
                    return "My friends and their friends";
                case FileAccess.PeopleWithALink:
                    return "People with a link";
            }
            return "";
        }
    }
}
